import os

def getFiles(dir = "."):
	files = []
	for i in os.listdir(dir):
		if i.split(".")[-1] == "cpp":
			files.append(i)
	
	if len(files) == 0:
		raise Exception("No cpp files found")
	return files

IncludePath = ['../']
LibsPath = ['../libwebgen']
Libs = ['webgen']

CommonFlags = ' -Wall -pedantic'

debug = ARGUMENTS.get('debug', 0)
progenv = Environment(CPPFLAGS = CommonFlags)
if int(debug):
	progenv.Append(CPPFLAGS = ' -g')

files = []

try:
	files = getFiles()
except Exception,e:
	print e
	exit()

for i in getFiles():
	progenv.Program(target = i.split(".")[0], source = i, CPPPATH = IncludePath, LIBS = Libs, LIBPATH = LibsPath)


